<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="订单编号">
              <a-input placeholder="请输入昵称" v-model="queryParam.payOrderNo"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="用户昵称">
              <a-input placeholder="请输入昵称" v-model="queryParam.uid"></a-input>
            </a-form-item>
          </a-col>

          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="支付方式">
              <j-dict-select-tag placeholder="请输入支付方式" v-model="queryParam.payChannel"  dictCode="pay_cannel"
                style="width: 200px" />
            </a-form-item>
          </a-col>

          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="类型">
              <j-dict-select-tag placeholder="请选择类型" v-model="queryParam.type"  dictCode="order_pay_type"
                style="width: 200px" />
            </a-form-item>
          </a-col>

          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="订单状态">
              <j-dict-select-tag placeholder="请选择状态" v-model="queryParam.status"  dictCode="order_pay_status"
                style="width: 200px" />
            </a-form-item>
          </a-col>

          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">

      <a-button type="primary" icon="download" @click="handleExportXls('oms_pay_order')">导出</a-button>

    </div>

    <!-- table区域-begin -->
    <div>
      <!-- <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div> -->

      <a-table ref="table" size="middle" :scroll="{x:true}" bordered rowKey="id" :columns="columns" :dataSource="dataSource" :pagination="ipagination"
        :loading="loading" class="j-table-force-nowrap" @change="handleTableChange">

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" height="55px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;" />
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button v-else :ghost="true" type="primary" icon="download" size="small" @click="downloadFile(text)">
            下载
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">
          <router-link :to="{name:'order-OmsPayOrderInfo', params: {record}}">
            <a>查看</a>
          </router-link>
          <a-divider type="vertical" />
          <a-dropdown>
            <a class="ant-dropdown-link">更多
              <a-icon type="down" />
            </a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a @click="handleDetail(record)">详情</a>
              </a-menu-item>
              <a-menu-item>
                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>

      </a-table>
    </div>

    <oms-pay-order-modal ref="modalForm" @ok="modalFormOk"></oms-pay-order-modal>
  </a-card>
</template>

<script>

import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/MyJeecgListMixin'
import OmsPayOrderModal from './modules/OmsPayOrderModal'

export default {
  name: 'OmsPayOrderList',
  mixins: [JeecgListMixin, mixinDevice],
  components: {
    OmsPayOrderModal
  },
  data () {
    return {
      description: 'oms_pay_order管理页面',
      // 表头
      columns: [
        {
          title: '序号',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: "center",
          customRender: function (t, r, index) {
            return parseInt(index) + 1
          }
        },
        {
          title: '支付订单号',
          align: "center",
          dataIndex: 'payOrderNo'
        },
        {
          title: '用户ID',
          align: "center",
          dataIndex: 'userNickname'
        },
        {
          // title:'1=商城订单，2=充值会员，3=充值钱包，4=预售单-定金，5=预售单-尾款',
          title: '订单类类型',
          align: "center",
          dataIndex: 'type_dictText'
        },
        {
          title: '支付金额',
          align: "center",
          dataIndex: 'payAmount'
        },
        {
          // title:'支付渠道:0=余额支付,1=支付宝支付,2=微信支付,3=公众号支付,4=小程序支付,5=apple pay,6=数字资产支付',
          title: '支付方式',
          align: "center",
          dataIndex: 'payChannel_dictText'
        },
        {
          title: '第三方支付流水号',
          align: "center",
          dataIndex: 'tradeNo'
        },
        {
          // title:'0:待支付,1:支付成功,2:支付失败3.关闭',
          title: '状态',
          align: "center",
          dataIndex: 'status_dictText'
        },
        {
          title: '支付时间',
          align: "center",
          dataIndex: 'createTime',
          customRender: function (text) {
            return !text ? "" : (text.length > 10 ? text.substr(0, 10) : text)
          }
        },
        // {
        //   title:'修改时间',
        //   align:"center",
        //   dataIndex: 'updateTime',
        //   customRender:function (text) {
        //     return !text?"":(text.length>10?text.substr(0,10):text)
        //   }
        // },
        {
          title: '额外参数',
          align: "center",
          dataIndex: 'ext'
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: "center",
          fixed: "right",
          width: 147,
          scopedSlots: { customRender: 'action' }
        }
      ],
      url: {
        list: "/mallBase/omsPayOrder/list",
        delete: "/mallBase/omsPayOrder/delete",
        deleteBatch: "/mallBase/omsPayOrder/deleteBatch",
        exportXlsUrl: "/mallBase/omsPayOrder/exportXls",
        importExcelUrl: "/mallBase/omsPayOrder/importExcel",

      },
      dictOptions: {},
    }
  },
  created () {
    if (this.$route.query.id) {
      this.queryParam.uid = this.$route.query.id
    }
    this.loadData()
  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
    },
  },
  methods: {
    initDictConfig () {
    }
  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>